Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.

Avoid trouble with shutting down HTTPClient #45

Merged
merged 1 commit into from
Jun 22, 2020

Conversation

ktoso
Copy link
Collaborator

@ktoso ktoso commented Jun 22, 2020

No description provided.

@ktoso ktoso force-pushed the usecase/end-to-end branch from f4803f7 to 9988a3a Compare June 22, 2020 13:33
@ktoso ktoso force-pushed the usecase/end-to-end branch from 9988a3a to c20ae2a Compare June 22, 2020 13:45
@ktoso ktoso requested a review from slashmo June 22, 2020 13:45
@@ -6,21 +6,36 @@ import NIO
import NIOHTTP1

struct InstrumentedHTTPClient {
private let client = HTTPClient(eventLoopGroupProvider: .createNew)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we were ignoring the init's passed in value here; so fixed this

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, how did I miss that? 🤦‍♂️😁

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happens :)

@@ -9,15 +9,15 @@ import NIOHTTP1
import NIO

let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
let threadPool = NIOThreadPool(numberOfThreads: 6)
threadPool.start()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think we'll need one?

@@ -57,8 +56,9 @@ httpClient.get(url: "http://localhost:8080").whenComplete { result in
sleep(20)

try httpClient.syncShutdown()
try orderServiceChannel.close().wait()
try storageServiceChannel.close().wait()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we don't really have to right now since we kill the EL, but this would be a good way if we had any cleanup to do in channelRemoved -- but we don't... So consider this optional here I guess

@@ -6,21 +6,36 @@ import NIO
import NIOHTTP1

struct InstrumentedHTTPClient {
private let client = HTTPClient(eventLoopGroupProvider: .createNew)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, how did I miss that? 🤦‍♂️😁


let orderServiceBootstrap = ServerBootstrap(group: eventLoopGroup)
.serverChannelOption(ChannelOptions.backlog, value: 256)
.serverChannelOption(ChannelOptions.socketOption(.so_reuseaddr), value: 1)
.childChannelInitializer { channel in
channel.pipeline.configureHTTPServerPipeline().flatMap {
channel.pipeline.addHandler(OrderServiceHandler(instrument: FakeTracer()))
channel.pipeline.addHandler(OrderServiceHandler(httpClient: httpClient, instrument: FakeTracer()))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@slashmo slashmo merged commit 2c3bb69 into slashmo:usecase/end-to-end Jun 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants